package com.shop2cn.iapi.sqpayment.testcase;

import java.util.List;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.dguser.parameter.UserCreateBean;
import com.ymatou.iapi.godmch.parameter.CreateCodeBean;
import com.ymatou.iapi.godmch.parameter.bindmchBean;
import com.ymatou.iapi.godmch.parameter.createagentBean;
import com.ymatou.iapi.godmch.parameter.createmchBean;
import com.ymatou.iapi.godmch.parameter.setShareTypeBean;
import com.ymatou.iapi.godmch.service.CreateCodeCall;
import com.shop2cn.iapi.sqpayment.parameter.QueryGodH5MchInfoBean;
import com.shop2cn.iapi.sqpayment.service.QueryGodH5MchInfoCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.DGUserCallService;
import com.ymttest.business.service.SQPayGateWayCallService;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
/**
*神器H5支付商户信息查询
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_QueryGodH5MchInfo{
	private static QueryGodH5MchInfoBean querygodh5mchinfoBean;
	private static QueryGodH5MchInfoCall querygodh5mchinfoCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("神器H5支付商户信息查询");
	}

	@Before
	public void caseUp() {
		querygodh5mchinfoBean=new QueryGodH5MchInfoBean();
		querygodh5mchinfoCall=new QueryGodH5MchInfoCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(querygodh5mchinfoCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryGodH5MchInfo_001() {
		Logger.start(true,"神器H5支付商户信息查询成功h5sqBuyer公共版");
		try {
			//merchantconfig
			querygodh5mchinfoBean.setAppName("h5sqBuyer");
			querygodh5mchinfoBean.setSellerId(SQPayGateWayCallService.GdSq);
			querygodh5mchinfoCall.setData(querygodh5mchinfoBean);
			querygodh5mchinfoCall.callService();			
			Logger.verifyEquals("0", querygodh5mchinfoCall.getString("ErrorCode"), "验证ErrorCode");
			//"Result":{"MchNo":"WC5c78d78282174","AppName":"500009816"}
			Logger.verifyEquals("h5sqBuyer", querygodh5mchinfoCall.getJsonObject().get("Result").getAsJsonObject().get("AppName").getAsString(),"验证appname");
			Logger.verifyNotNull(querygodh5mchinfoCall.getJsonObject().get("Result").getAsJsonObject().get("MchNo").getAsString(),"验证MchNo");
			Logger.verifyEquals(SQPayGateWayCallService.GdDefMerchantNo, querygodh5mchinfoCall.getJsonObject().get("Result").getAsJsonObject().get("MchNo").getAsString(),"验证返回");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_QueryGodH5MchInfo_002() {
		Logger.start(true,"不输入appname失败");
		try {
//			querygodh5mchinfoBean.setAppName("h5sqBuyer");
			querygodh5mchinfoBean.setSellerId(SQPayGateWayCallService.PayGdSq.toString());
			querygodh5mchinfoCall.setData(querygodh5mchinfoBean);
			querygodh5mchinfoCall.callService();			
			Logger.verifyEquals("1000", querygodh5mchinfoCall.getString("ErrorCode"), "验证ErrorCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_QueryGodH5MchInfo_003() {
		Logger.start(true,"不输入SellerId失败");
		try {
			querygodh5mchinfoBean.setAppName("h5sqBuyer");
//			querygodh5mchinfoBean.setSellerId(SQPayGateWayCallService.PayGdSq.toString());
			querygodh5mchinfoCall.setData(querygodh5mchinfoBean);
			querygodh5mchinfoCall.callService();			
			Logger.verifyEquals("1000", querygodh5mchinfoCall.getString("ErrorCode"), "验证ErrorCode");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	@Ignore
	//appname 目前没有用
	public void Tc_QueryGodH5MchInfo_004() {
		Logger.start(true,"输入appname错误失败");
		try {
			querygodh5mchinfoBean.setAppName("123");
			querygodh5mchinfoBean.setSellerId(SQPayGateWayCallService.GdSq);
			querygodh5mchinfoCall.setData(querygodh5mchinfoBean);
			querygodh5mchinfoCall.callService();			
			Logger.verifyEquals("1000", querygodh5mchinfoCall.getString("ErrorCode"), "验证ErrorCode");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_QueryGodH5MchInfo_005() {
		Logger.start(true,"输入SellerId不支持H5支付-默认1hipopay");
		try {
			querygodh5mchinfoBean.setAppName("h5sqBuyer");
			querygodh5mchinfoBean.setSellerId("1");
			querygodh5mchinfoCall.setData(querygodh5mchinfoBean);
			querygodh5mchinfoCall.callService();			
			Logger.verifyEquals("h5sqBuyer", querygodh5mchinfoCall.getJsonObject().get("Result").getAsJsonObject().get("AppName").getAsString(),"验证appname");
			Logger.verifyNotNull(querygodh5mchinfoCall.getJsonObject().get("Result").getAsJsonObject().get("MchNo").getAsString(),"验证MchNo");
			Logger.verifyEquals(SQPayGateWayCallService.GdDefMerchantNo, querygodh5mchinfoCall.getJsonObject().get("Result").getAsJsonObject().get("MchNo").getAsString(),"验证返回");

			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_QueryGodH5MchInfo_006() {
		Logger.start(true,"神器H5支付商户信息查询成功h5sqBuyer独立版");
		try {
			//查询配置表 paygateway.merchantconfig
			//固定数据
			querygodh5mchinfoBean.setAppName("h5sqBuyer");
			querygodh5mchinfoBean.setSellerId(SQPayGateWayCallService.GdH5Sq);
			querygodh5mchinfoCall.setData(querygodh5mchinfoBean);
			querygodh5mchinfoCall.callService();			
			Logger.verifyEquals("0", querygodh5mchinfoCall.getString("ErrorCode"), "验证ErrorCode");
			//"Result":{"MchNo":"WC5c78d78282174","AppName":"500009816"}
			Logger.verifyEquals(querygodh5mchinfoBean.getSellerId(), querygodh5mchinfoCall.getJsonObject().get("Result").getAsJsonObject().get("AppName").getAsString(),"验证appname");
			Logger.verifyNotNull(querygodh5mchinfoCall.getJsonObject().get("Result").getAsJsonObject().get("MchNo").getAsString(),"验证MchNo");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	//20190924-微信支付合规问题-继承H5要用对应的支付否则会被微信封
	public void Tc_QueryGodH5MchInfo_007() {
		Logger.start(true,"神器H5支付商户信息查询成功h5sqBuyer独立版-独立的代理商用独立商户信息做支付");
		try {
			//查询配置表 paygateway.merchantconfig
			//固定数据
			//创建代理用户id
			UserCreateBean usercreateBean=DGUserCallService.initUsercreateBean();
			Integer userId_agent=DGUserCallService.UserCreateCall(usercreateBean);
			List<createmchBean> createmchList=GodmchManageCallService.InitcreatemchBeanForAgent(Integer.valueOf(SQPayGateWayCallService.GdH5Sq), userId_agent);
			GodmchManageCallService.createmchCallForAgent(createmchList.toArray(new
			     createmchBean[createmchList.size()]));
			Thread.sleep(2000);
			querygodh5mchinfoBean.setAppName("h5sqBuyer");
			querygodh5mchinfoBean.setSellerId(userId_agent.toString());
			querygodh5mchinfoCall.setData(querygodh5mchinfoBean);
			querygodh5mchinfoCall.callService();			
			Logger.verifyEquals("0", querygodh5mchinfoCall.getString("ErrorCode"), "验证ErrorCode");
			//"Result":{"MchNo":"WC5c78d78282174","AppName":"500009816"}
			Logger.verifyEquals(userId_agent.toString(), querygodh5mchinfoCall.getJsonObject().get("Result").getAsJsonObject().get("AppName").getAsString(),"验证appname");
			Logger.verifyNotNull(querygodh5mchinfoCall.getJsonObject().get("Result").getAsJsonObject().get("MchNo").getAsString(),"验证MchNo");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_QueryGodH5MchInfo_008() {
		Logger.start(true,"神器H5支付商户信息查询成功h5sqBuyer公共版-增加神器H5按照商户进行支付渠道路由");
		try {
			//静态配置 6000 的 商户指向6002商户号
			//merchantconfig
			querygodh5mchinfoBean.setAppName("h5sqBuyer");
			querygodh5mchinfoBean.setSellerId("6000");
			querygodh5mchinfoCall.setData(querygodh5mchinfoBean);
			querygodh5mchinfoCall.callService();			
			Logger.verifyEquals("0", querygodh5mchinfoCall.getString("ErrorCode"), "验证ErrorCode");
			//"Result":{"MchNo":"WC5c78d78282174","AppName":"500009816"}
			Logger.verifyEquals("h5sqBuyer", querygodh5mchinfoCall.getJsonObject().get("Result").getAsJsonObject().get("AppName").getAsString(),"验证appname");
			Logger.verifyNotNull(querygodh5mchinfoCall.getJsonObject().get("Result").getAsJsonObject().get("MchNo").getAsString(),"验证MchNo");
			Logger.verifyEquals(SQPayGateWayCallService.GdDefMerchantNo_6002, querygodh5mchinfoCall.getJsonObject().get("Result").getAsJsonObject().get("MchNo").getAsString(),"验证返回");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryGodH5MchInfo_009() {
		//http://jira.ymatou.cn:8080/browse/JIRACONN-35474 越洋电铺代理商H5支付取消对渠道商资金渠道的检查 查询MchNo返回root
		Logger.start(true,"神器H5支付商户信息查询成功h5sqBuyer公共版-增加字段RootSellerId");
		try {
			UserCreateBean usercreateBean=DGUserCallService.initUsercreateBean();
			Integer userId_agent=DGUserCallService.UserCreateCall(usercreateBean);
			List<createmchBean> createmchList=GodmchManageCallService.InitcreatemchBeanForAgent(Integer.valueOf(SQPayGateWayCallService.GdH5Sq), userId_agent);
			GodmchManageCallService.createmchCallForAgent(createmchList.toArray(new
			     createmchBean[createmchList.size()]));
			Thread.sleep(1000);
			querygodh5mchinfoBean.setAppName("h5sqBuyer");
			querygodh5mchinfoBean.setSellerId(userId_agent.toString());
			querygodh5mchinfoBean.setRootSellerId(SQPayGateWayCallService.GdSq);
			querygodh5mchinfoCall.setData(querygodh5mchinfoBean);
			querygodh5mchinfoCall.callService();			
			Logger.verifyEquals("0", querygodh5mchinfoCall.getString("ErrorCode"), "验证ErrorCode");
			//"Result":{"MchNo":"WC5c78d78282174","AppName":"500009816"}
			Logger.verifyEquals(userId_agent.toString(), querygodh5mchinfoCall.getJsonObject().get("Result").getAsJsonObject().get("AppName").getAsString(),"验证appname");
			Logger.verifyNotNull(querygodh5mchinfoCall.getJsonObject().get("Result").getAsJsonObject().get("MchNo").getAsString(),"验证MchNo");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryGodH5MchInfo_010() {
		Logger.start(true,"神器H5支付商户信息查询成功h5sqBuyer公共版-sft");
		try {
			Integer mchId_channl = GodmchManageCallService.CreateSellerMch();
			setShareTypeBean bean=new setShareTypeBean();
			bean.setAliPayMode(0);
			bean.setDualMode(0);
			bean.setMchId(mchId_channl);
			bean.setMchShareType(1);
			bean.setPayMode(3);
			bean.setMchSideBuy(1);
			GodmchManageCallService.setShareTypeV2Call(bean);
			Thread.sleep(3000);
			querygodh5mchinfoBean.setGodPayCompany(2);
			querygodh5mchinfoBean.setAppName("h5sqBuyer");
			querygodh5mchinfoBean.setSellerId(mchId_channl.toString());
			querygodh5mchinfoCall.setData(querygodh5mchinfoBean);
			querygodh5mchinfoCall.callService();			
			Logger.verifyEquals("0", querygodh5mchinfoCall.getString("ErrorCode"), "验证ErrorCode");
			//"Result":{"MchNo":"WC5c78d78282174","AppName":"500009816"}
			Logger.verifyEquals("h5sqBuyer", querygodh5mchinfoCall.getJsonObject().get("Result").getAsJsonObject().get("AppName").getAsString(),"验证appname");
			Logger.verifyNotNull(querygodh5mchinfoCall.getJsonObject().get("Result").getAsJsonObject().get("MchNo").getAsString(),"验证MchNo");
			Logger.verifyEquals(SQPayGateWayCallService.SFTMerchantNo, querygodh5mchinfoCall.getJsonObject().get("Result").getAsJsonObject().get("MchNo").getAsString(),"验证返回");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryGodH5MchInfo_011() {
		//http://jira.ymatou.cn:8080/browse/JIRACONN-38575
		Logger.start(true,"神器H5支付商户信息查询成功h5sqBuyer公共版-内购appname传入appsqSeller");
		try {
			//merchantconfig
			querygodh5mchinfoBean.setAppName("AppsqSeller");
			querygodh5mchinfoBean.setSellerId(SQPayGateWayCallService.GdSq);
			querygodh5mchinfoCall.setData(querygodh5mchinfoBean);
			querygodh5mchinfoCall.callService();			
			Logger.verifyEquals("0", querygodh5mchinfoCall.getString("ErrorCode"), "验证ErrorCode");
			//"Result":{"MchNo":"WC5c78d78282174","AppName":"500009816"}
			Logger.verifyEquals("h5sqBuyer", querygodh5mchinfoCall.getJsonObject().get("Result").getAsJsonObject().get("AppName").getAsString(),"验证appname");
			Logger.verifyNotNull(querygodh5mchinfoCall.getJsonObject().get("Result").getAsJsonObject().get("MchNo").getAsString(),"验证MchNo");
			Logger.verifyEquals(SQPayGateWayCallService.GdDefMerchantNo, querygodh5mchinfoCall.getJsonObject().get("Result").getAsJsonObject().get("MchNo").getAsString(),"验证返回");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryGodH5MchInfo_012() {
		Logger.start(true,"神器H5支付商户信息查询成功-查不到的时候godPayCompany=hipopay 返回appname=h5sqBuyer,MchNo=HipoPayWxH5(6001)的商户号");
		try {
			Integer mchId_channl = GodmchManageCallService.CreateSellerMch();
			setShareTypeBean bean=new setShareTypeBean();
			bean.setAliPayMode(0);
			bean.setDualMode(0);
			bean.setMchId(mchId_channl);
			bean.setMchShareType(1);
			bean.setPayMode(0);
			bean.setMchSideBuy(1);
			bean.setDomesticPayMode(1);
			GodmchManageCallService.setShareTypeV2Call(bean);
			Thread.sleep(3000);
			querygodh5mchinfoBean.setGodPayCompany(1);
			querygodh5mchinfoBean.setAppName("h5sqBuyer");
			querygodh5mchinfoBean.setSellerId(mchId_channl.toString());
			querygodh5mchinfoCall.setData(querygodh5mchinfoBean);
			querygodh5mchinfoCall.callService();			
			Logger.verifyEquals("0", querygodh5mchinfoCall.getString("ErrorCode"), "验证ErrorCode");
			//"Result":{"MchNo":"WC5c78d78282174","AppName":"500009816"}
			Logger.verifyEquals("h5sqBuyer", querygodh5mchinfoCall.getJsonObject().get("Result").getAsJsonObject().get("AppName").getAsString(),"验证appname");
			Logger.verifyNotNull(querygodh5mchinfoCall.getJsonObject().get("Result").getAsJsonObject().get("MchNo").getAsString(),"验证MchNo");
			Logger.verifyEquals(SQPayGateWayCallService.GdDefMerchantNo, querygodh5mchinfoCall.getJsonObject().get("Result").getAsJsonObject().get("MchNo").getAsString(),"验证返回");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryGodH5MchInfo_013() {
		Logger.start(true,"神器H5支付商户信息查询成功-查不到的时候godPayCompany=盛付通 返回appname=h5sqBuyer,MchNo=PayTypeEnum.ShengPayWxGzh,6011的商户号");
		try {
			Integer mchId_channl = GodmchManageCallService.CreateSellerMch();
			setShareTypeBean bean=new setShareTypeBean();
			bean.setAliPayMode(0);
			bean.setDualMode(0);
			bean.setMchId(mchId_channl);
			bean.setMchShareType(1);
			bean.setPayMode(1);
			bean.setMchSideBuy(1);
			bean.setDomesticPayMode(0);
			GodmchManageCallService.setShareTypeV2Call(bean);
			Thread.sleep(3000);
			querygodh5mchinfoBean.setGodPayCompany(2);
			querygodh5mchinfoBean.setAppName("h5sqBuyer");
			querygodh5mchinfoBean.setSellerId(mchId_channl.toString());
			querygodh5mchinfoCall.setData(querygodh5mchinfoBean);
			querygodh5mchinfoCall.callService();			
			Logger.verifyEquals("0", querygodh5mchinfoCall.getString("ErrorCode"), "验证ErrorCode");
			//"Result":{"MchNo":"WC5c78d78282174","AppName":"500009816"}
			Logger.verifyEquals("h5sqBuyer", querygodh5mchinfoCall.getJsonObject().get("Result").getAsJsonObject().get("AppName").getAsString(),"验证appname");
			Logger.verifyNotNull(querygodh5mchinfoCall.getJsonObject().get("Result").getAsJsonObject().get("MchNo").getAsString(),"验证MchNo");
			Logger.verifyEquals(SQPayGateWayCallService.SFTMerchantNo, querygodh5mchinfoCall.getJsonObject().get("Result").getAsJsonObject().get("MchNo").getAsString(),"验证返回");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}